<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>v-bind</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
  <h1>v-bind</h1>
  <hr>
  <div id="app">
    <img v-bind:src="imgSrc" width="200px"><br>
    <a v-bind:href="webUrl" target="_blank">百度</a>
    <a :href="webUrl" target="_blank">百度</a>
    <div :class="className"> 1、绑定class</div>
    <button @click="changeClass">改变绑定class</button>
    <div :class="{classA:isOk}"> 2、绑定class判断</div>
    <div :class="[classA,classB]"> 3、绑定class数组</div>
    <div :class="isOk?classA:classB"> 4、绑定class 三元运算符</div>
    <hr>
    <div>
      <input type="checkbox" id="cb1" v-model="isOk">
      <label for="cb1">{{isOk}}</label>
    </div>
    <div :style="{color:color,fontSize:font}">5、绑定style</div>
    <div :style="styleObject">6、绑定style对象</div>
    
    
  </div>
  <style>
    .classA{
      color:red;
    }
    .classB{
      font-size: 150%;
    }
  </style>
  <script type="text/javascript">
  var app = new Vue({
    el:'#app',
    data:{
      imgSrc:'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.juimg.com%2Ftuku%2Fyulantu%2F140703%2F330746-140f301555752.jpg&refer=http%3A%2F%2Fimg.juimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1622257364&t=96c7a1895c714dd8fd6ddc4eec4e1b71',
      webUrl:'https://www.baidu.com',
      className:'classA',
      isOk:true,
      classA:'classA',
      classB:'classB',
      color:'red',
      font:'20px',
      styleObject:{
        color:'green',
      font:'20px',
      }
    },
    methods:{
      changeClass:function(){
        this.isOk = !this.isOk;
        if(this.className == 'classA'){
          this.className = 'classB';
        }
        else{
          this.className = 'classA';
        }
      },
    }
  })
  </script>
</body>
</html>